import { createSlice } from "@reduxjs/toolkit";
import { RootState } from "../index";

interface themeState {
  themeColor: boolean;
  borderColor:string;
  drawerState: boolean;
}

const initialState: themeState = {
  //全局主题
  themeColor: false,
  //全局主题边框
  borderColor: "#F5F5F5",
  //添加的弹窗
  drawerState: false,
};

const themeStore = createSlice({
  name: "theme",
  initialState,
  reducers: {
    changeThemeColor(state, action) {
      state.themeColor = action.payload;
    },

    changeBorderState(state, action) {
      state.borderColor = action.payload
    },

    changeDrawerState(state, action) {
      state.drawerState = action.payload;
    },
  },
});

export const selectTheme = (state: RootState) => state.theme.themeColor;
export const selectDrawer = (state: RootState) => state.theme.drawerState;
export const { changeThemeColor, changeDrawerState,changeBorderState } = themeStore.actions;
export default themeStore.reducer;
